package excel

import "fmt"

const (
	CellTypeTxt = 1
	CellTypeImg = 2
)

type Cell struct {
	file *File

	//1.txt 2.img
	Type int

	//行序号 从1开始
	RowIndex int

	//列序号 从1开始
	ColIndex int

	//key，对应globalbase.CMap的key,用于title行对应实际数据的字段
	Key string

	//值
	Value any
}

func (c *Cell) WithKeyValue(key string, value any) *Cell {
	c.Key = key
	c.Value = value
	return c
}

func (c *Cell) GetLabel() string {
	return fmt.Sprintf("%s%d", ColLabel(c.ColIndex), c.RowIndex)
}

func (c *Cell) IsTxt() bool {
	return c.Type == CellTypeTxt
}

func (c *Cell) IsImg() bool {
	return c.Type == CellTypeImg
}

// func (c *Cell) GetImgs() error {
// 	pics, err := file.F.GetPictures(file.GetFirstSheetName(), c.GetLabel())
// 	if err != nil {
// 		return err
// 	}
// 	return pics
// }

func NewCell(rowIndex int, colIndex int) *Cell {
	return &Cell{RowIndex: rowIndex, ColIndex: colIndex}
}
